<template>
    <h1>医生添加</h1>
    <table class="table" border="1">
        <tbody>
            <tr>
                <td>医生名称</td>
                <td>
                    <input type="text" v-model="Info.dName"/>
                </td>
            </tr>
            <tr>
                <td>科室</td>
                <td >
                    <select v-model="Info.kId">
                        <option value="-1">--请选择--</option>
                        <option v-for="item in bang" :value="item.kId">{{ item.kName }}</option>
                    </select>
                </td>
            </tr>
            <tr>
                <td>职称</td>
                <td>
                    <select v-model="Info.zhiCheng">
                        <option value="请选择">--请选择--</option>
                        <option value="主治医生">主治医生</option>
                        <option value="非主治医生">非主治医生</option>
                        <option value="主刀医生">主刀医生</option>
                        <option value="非主刀医生">非主刀医生</option>
                    </select>
                </td>
            </tr>
            <tr>
                <td>第一职业医院</td>
                <td>
                    <select v-model="Info.xueli">
                        <option value="请选择">--请选择--</option>
                        <option value="北大人民医院">北大人民医院</option>
                        <option value="清华人民医院">清华人民医院</option>
                        <option value="协和人民医院">协和人民医院</option>
                        <option value="北京人民医院">北京人民医院</option>
                    </select>
                </td>
            </tr>
            <tr>
                <td>是否开通账号</td>
                <td>
                    <input type="radio" :value="0" v-model="Info.isKai"/>已开通
                    <input type="radio" :value="1" v-model="Info.isKai"/>未开通
                </td>
            </tr>
            <tr>
                <td>类型</td>
                <td>
                    <input type="text" v-model="Info.type"/>
                </td>
            </tr>
            <tr>
                <td>创建时间</td>
                <td>
                    <input type="date" v-model="Info.dCraDate"/>
                </td>
            </tr>
            <tr>
                <td>更新时间</td>
                <td>
                    <input type="date" v-model="Info.dGengDate"/>
                </td>
            </tr>
            <tr>
                <td>医生照片</td>
                <td>
                   
                    <input type="file" @click="Upload"/>
                </td>
            </tr>
            <tr>
                <td colspan="2" style="text-align: center;">
                    <input type="button" value="保存" @click="Add"/>
                </td>
            </tr>
        </tbody>
    </table>
</template>

<script setup lang="ts">
import { ref,onMounted } from "vue";
import axios from "axios";
import { useRouter } from "vue-router";
onMounted(()=>{
    bing();
})

const bang = ref([{
    "kId": 0,
  "kName": "",
}])

const bing=()=>{
    axios.get("https://localhost:7199/api/BingRoom/GetKeAll")
    .then(res=>{
        bang.value=res.data
    })
    .catch(error=>{
        console.log(error);
    })
}

const Info=ref({
    "id": 0,
  "dName": "",
  "kId": 0,
  "xueli": "",
  "zhiCheng": "",
  "isKai": 0,
  "type": "",
  "img": "",
  "dCraDate": "",
  "dGengDate": "",
  "isDel": 0
})

const router=useRouter();
const Add=()=>{
    if(Info.value.dName==""){
        alert("医生姓名不能为空")
    }
    axios.post("https://localhost:7199/api/Docater/Add",Info.value)
    .then(res=>{
         if(res.data>0){
            alert("添加成功！")
            router.push("/ShowDocater")
        }
        else{
            alert("添加失败")
        }
    })
    .catch(error=>{
        console.log(error);
    })
}

const Upload=()=>{
   alert("上传成功")

}
</script>